package com.lc.mail.controller;

import com.lc.mail.service.MailService;
import com.study.common.entity.bo.BatchMailBo;
import com.study.common.entity.bo.MailBo;
import com.study.common.res.ApiResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @description: some desc
 * @author: LChuang
 * @date: 2023/9/26 17:39
 */
@RestController
@RequestMapping("/mail")
public class MailController {

    @Resource
    private MailService mailService;


    @PostMapping("/normal")
    public ApiResult normal(@Validated @RequestBody MailBo bo){
        String res = mailService.normalMail(bo);
        return ApiResult.success(res);
    }


    @PostMapping("/html")
    public ApiResult html(@Validated @RequestBody MailBo bo){
        String res = mailService.htmlMail(bo);
        return ApiResult.success(res);
    }


    /**
     * 使用postman测试该接口，参数全部设置在Body-->form-data中，设置Content-Type为application/json
     * postman设置参数名与接口参数名对应即可；
     * 接口使用@RequestPart注解！！
     */
    @PostMapping("/annex")
    public ApiResult annex(@Validated @RequestPart MailBo bo, @RequestPart MultipartFile file){
        String res = mailService.annexMail(bo, file);
        return ApiResult.success(res);
    }
}
